package com.lifesaftypower.product;

import java.io.Serializable;
import java.util.ArrayList;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class ProductCategory implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String TAG = "category";
	private String _name;
	private ArrayList<ProductSeries> _series;

	public ProductCategory(Node xmlNode) {
		if (xmlNode.getNodeType() == Node.ELEMENT_NODE) {
			Element _xmlNode = (Element) xmlNode;
			_name = _xmlNode.getAttribute("name");

			_series = new ArrayList<ProductSeries>();

			NodeList seriesNodes = _xmlNode
					.getElementsByTagName(ProductSeries.TAG);
			for (int i = 0; i < seriesNodes.getLength(); i++) {
				_series.add(new ProductSeries(seriesNodes.item(i)));
			}
		}
	}

	public ProductCategory(String _name) {
		this._name = _name;
	}

	public String get_name() {
		return _name;
	}

	public ArrayList<ProductSeries> get_series() {
		return _series;
	}

	@Override
	public String toString() {
		return "ProductCategory [_name=" + _name + "]";
	}

}
